New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add a cumsum transform to cumulatively sum a single column #7961
Conversation
With this PR the SO question can be achieved much more cleanly with:
|
result[0] = 0 | ||
else | ||
result[0] = col[0] | ||
debugger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should really just make a code quality check that looks for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, there's a built-in rule for this (https://palantir.github.io/tslint/rules/no-debugger/).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in c591751
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If your are at fixing things, you can add "no-debugger": true
to bokehjs/tslint.json
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a part of codebase
job on travis ci. Otherwise you have to run node make tslint
. Perhaps we could make it part of quality
tests at some point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it doesn't currently actually fail when there is a violation:
It was supposed to get --emit-error
, the same as scripts:compile
and test:compile
have. Must have forgotten about this or maybe there is a regression since then new build is in place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I added it, tho as I said it's not clear to me that a linter failure results in a test failure since the exit always seems to be 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried adding --emit-error
locally, that still did not result in a nonzero exit code when a lint violation was present
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact this was done on purpose, because initially tslint reported a lot of errors and it was tedious dealing with this. Now all were resolved, so failing tslint
build task on error should be implemented. I will do it with the next round of build improvements.
bokeh/models/expressions.py
Outdated
|
||
source = ColumnDataSource(data=dict(foo=[1, 2, 3, 4])) | ||
|
||
CumSum('foo') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do Expressions
actually allow positional arguments? Might be the case but maybe you confused it with the cumsum helper function signature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this code is incorrect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it would be good to use actual Python shell syntax (>>>
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 7f2a0dc
if (this.include_zero) | ||
result[0] = 0 | ||
else | ||
result[0] = col[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could have been reduced to one line as on the line before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 0c3eaa9
I ran across the SO question Create pie-chart using bokeh with dictionary
and thought I woudl see if it could be done with
Stack
but soon realized that it could not, sinceStack
stacks multiple entire columns element-wise. It occured to me that a cummulative sum was a very useful but missing piece that would also be trivial to implement, so I threw together this PR.I will add docs and tests in subsequent commits.